#include <iostream>
#include <fstream>
#include <sstream>
#include <string>
#include <map>
using namespace std;

//#define READ_FILE

map<string, string> g_map;

int main()
{
#ifdef READ_FILE
	ifstream in("1109.input");
	if (!in) { in.open("../1109.input"); }
#else
	#define in cin
#endif

	string buf;
	getline(in, buf);
	while (buf.length() > 0)
	{
		istringstream strIn(buf);
		string str1, str2;
		strIn >> str1 >> str2;
		g_map[str2] = str1;
		getline(in, buf);
	}
	
	while (in >> buf)
	{
		if (g_map.find(buf) != g_map.end())
		{
			cout << g_map[buf] << endl;
		}
		else
		{
			cout << "eh" << endl;
		}
	}
	
	return 0;
}